from PyQt5.QtWidgets import QMainWindow, QPushButton, QVBoxLayout, QWidget, QLabel, QCheckBox, QLineEdit
from PyQt5.QtCore import Qt
from plugs.KarDia_tou_ABel import SignInTask, HatchEggsTask, AutoBattleTask, MYRZX_IMGS
from device import DeviceADB
from utils.logger import Logger
from interface import Interface

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.setWindowTitle("MHR Helper")
        self.setGeometry(100, 100, 400, 300)
        self.initUI()
        self.logger = Logger()
        self.logger.info("Application started")
        print("Application started")

    def initUI(self):
        self.device = DeviceADB()
        self.interfaces = {}
        self.interfaces["IncubationRoom"] = Interface('IncubationRoom', device=self.device, imgs=MYRZX_IMGS['培育室'])

        self.sign_in_button = QPushButton("Start Sign In", self)
        self.sign_in_button.clicked.connect(
            lambda: self.interfaces["IncubationRoom"].start(SignInTask)
        )

        self.hatch_eggs_button = QPushButton("Start Hatch Eggs", self)
        self.hatch_eggs_button.clicked.connect(
            lambda: self.interfaces["IncubationRoom"].start(HatchEggsTask)
        )

        self.auto_battle_button = QPushButton("Start Auto Battle", self)
        self.auto_battle_button.clicked.connect(
            lambda: self.interfaces["IncubationRoom"].start(AutoBattleTask)
        )

        self.status_label = QLabel("Status: Idle", self)

        layout = QVBoxLayout()
        layout.addWidget(self.sign_in_button)
        layout.addWidget(self.hatch_eggs_button)
        layout.addWidget(self.auto_battle_button)
        layout.addWidget(self.status_label)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)

    def update_status(self, message):
        self.status_label.setText(f"Status: {message}")
        self.logger.info(f"Status updated to: {message}")